<?php

namespace app\api\logic;


use GuzzleHttp\Client;
use think\facade\Cache;

class AuthLogic extends BaseSDKLogic
{

//    // 获取用户信息
//    public function userInfo($code)
//    {
//        $configDing = \think\facade\Config::get('ding');
//
//
//        // 创建客户端请求
//        $client = new Client();
//        // 请求选项
//        $response = $client->request('POST',$configDing['host_old'].'/topapi/v2/user/getuserinfo',[
//            'headers' => [
//                'Content-Type' => 'application/json',
//            ],
//            'verify' => false,
//            'json' => ['code' => $code],
//            'query' => ['access_token' => $this->accessToken()],
//
//        ]);
//        $body = $response->getBody();
//        $stringBody = (string) $body;
//        return json_decode($stringBody,true);
//
//    }

    // 获取用户详情
    public function userDetails($userId)
    {
        $configDing = \think\facade\Config::get('ding');


        // 创建客户端请求
        $client = new Client();
        // 请求选项
        $response = $client->request('POST',$configDing['host_old'].'/topapi/v2/user/get',[
            'headers' => [
                'Content-Type' => 'application/json',
            ],
            'verify' => false,
            'json' => [
                'userid' => $userId

            ],
            'query' => ['access_token' => $this->accessToken()],

        ]);
        $body = $response->getBody();
        $stringBody = (string) $body;
        return json_decode($stringBody,true);

    }
}